#-*- encoding: utf-8 -*-
'''
Created on 2011-6-20

@author: Bob
'''

from SocketServer import TCPServer, StreamRequestHandler

class MyRequestHandler(StreamRequestHandler):
    def handler(self):
        print 'connected from:', self.client_address
        print(self.rfile.read(23))
        self.wfile.write('<cross-domain-policy><allow-access-from domain="*" to-ports="*"/></cross-domain-policy>')
        print 'send xml ok'

class FlashPolicyServer:
    server = None
    def start(self):
        self.server = TCPServer(('',843), MyRequestHandler)
        
        print 'waiting for connection...'
        self.server.serve_forever()
    def stop(self):
        self.server.shutdown()
        self.server.server_close()
        